<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 17.8.15
 * Time: 17:21
 */


/**
 * @param $errors
 * @return int|string
 */
function formatErrors($errors)
{
    $i = 0;
    $str = [];
    $messages = $errors->getMessages();
    foreach ($messages as $key => $value) {
        $str[] = ($value[0]);
    }

    $str = implode($str, "<br>");

    return $str;

}

function randString($length, $specialChars = false)
{
    $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
    if ($specialChars) {
        $chars .= '!@#$%^&*()';
    }

    $result = '';
    $max = strlen($chars) - 1;
    for ($i = 0; $i < $length; $i++) {
        $result .= $chars[rand(0, $max)];
    }
    return $result;
}

function isProduction()
{
    return env("APP_ENV", "local") === "production";
}